<?php // check for the user session 

			/*	session_start(); ?>
              <?php if(isset($_SESSION['user_id'])){
				  
				  header('Location: user-home.php'); } */
				  ?>

<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

	<title></title>
	<meta name="description" content="">
	<meta name="author" content="">

	<meta name="viewport" content="width=device-width">

	<link rel="stylesheet" href="css/bootstrap.min.css">
	<style>
	body {
	  padding-top: 60px;
	  padding-bottom: 40px;
	}
	</style>
	<link rel="stylesheet" href="css/bootstrap-responsive.min.css">
	<link rel="stylesheet" href="css/style.css">
	<script type="text/javascript" src="js/libs/jquery-1.7.2.min.js"></script>
	<script src="js/libs/modernizr-2.5.3-respond-1.1.0.min.js"></script>
</head>
<body>
<!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->

    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="index.php">E-library</a>
          <div class="nav-collapse">
            <ul class="nav">
              <li><a href="index.php">Home</a></li>

				  <li><a href="register.php">Register</a></li>
				  <li class="active"><a href="login.php">Log In</a></li>
			 
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

    <div class="container">

      <!-- Main hero unit for a primary marketing message or call to action -->
      <div>
      
      	<div class="small-box">
        
        
        <form id="login" class="well" method="post" action="logic/login-code.php"> 
        
        <h1>Login</h1>
        <hr>
        
            <label for="email" >Email</label> <input class="required span3" type="email" name="email" id="email" >
            
            <label for="password" >Password</label> <input class="required span3" type="password" id="password" name="password">
            
            <p><a id="forgot_password" href="forgot-password.php" >Forgot your password ?</a></p>
            
            <p><input type="submit" class="btn btn-primary btn-large" id="login_submit" value="Login"/></p>
        
        </form>
            
             <div id="login_error">
   			 </div>
             
             
             </div>
             <div class="clearfix"></div>
        
      </div>

     

      <hr>

      <footer>
        <p>&copy; Company 2012</p>
      </footer>

	

    </div> <!-- /container -->
    
    <script type="text/javascript">
	
		$("#login_submit").click(function(){

		  email=$("#email").val();
		  login_error = $("#login_error");
		  password=$("#password").val();
		  $.ajax({
		   type: "POST",
		   url: "logic/login-code.php",
		   data: "l_email="+email+"&l_password="+password,
		   success: function(html){
			
			if(html==='invalid_email')
			{
				login_error.html("<div class='alert alert-error'>Please provide a valid email address.</div>");
				} 
				
			else if(html==='blank_email_password')
			{
			 login_error.html("<div class='alert alert-error'>Email address or password cannot be blank</div>");
			}   
			   
			else if(html==='true')
			{		
			window.location='index.php';
			}
			else if(html==='inactive')
			{		
				login_error.html("<div class='alert alert-error'>Your account is not yet verified. Please verify first</div>");
			}
			else
			{
			 login_error.html("<div class='alert alert-error'>Email address and password didnot match</div>");
			}
		   },
		   beforeSend:function()
		   {
			login_error.html('<img src="img/ajax-loader.gif">')
		   }
		  });
		  return false;
		 });

	</script>

</body>
</html>
